package util;

import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.BaseFont;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

public class PDFConst {
    private static BaseFont simhei;//黑体
    private static Font simhei_nomal_9;//黑体，一般粗细，9号，用于标题字体
    private static Font simhei_nomal_10;//黑体，一般粗细，10号，用于表格中字体
    private static Image hoshine_image;//合盛logo
    private static final int cell_height = 25;//单元格高度
    static {
        try {//使用ClassPathResource方法加载最稳，其他方法或多或少在打包线上时有问题
            simhei = BaseFont.createFont(new ClassPathResource("font/simhei.ttf").getURL().toString(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            simhei_nomal_9 = new Font(simhei, 9f, Font.NORMAL);
            simhei_nomal_10 = new Font(simhei, 10.45f, Font.NORMAL);
            hoshine_image = Image.getInstance(new ClassPathResource("image/hoshine.png").getURL().toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static BaseFont getSimhei() {
        return simhei;
    }

    public static Font getSimhei_nomal_9() {
        return simhei_nomal_9;
    }

    public static Font getSimhei_nomal_10() {
        return simhei_nomal_10;
    }

    public static Image getHoshine_image() {
        return hoshine_image;
    }

    public static int getCell_height() {
        return cell_height;
    }
}
